package com.wd.tech.activity.activity;

import android.os.Bundle;
import android.widget.EditText;

import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
import androidx.viewpager.widget.ViewPager;

import com.google.android.material.tabs.TabLayout;
import com.wd.tech.R;
import com.wd.tech.activity.base.BaseActivity;
import com.wd.tech.activity.base.BasePreantert;
import com.wd.tech.activity.fragment.addfriend.FindGroupFragment;
import com.wd.tech.activity.fragment.addfriend.FindSomeoneFragment;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

//加好友页面
public class AddFriendActivity extends BaseActivity {

    @BindView(R.id.et_search)
    EditText etSearch;
    @BindView(R.id.vp)
    ViewPager vp;
    @BindView(R.id.tabs)
    TabLayout tabs;
    private List<String> tab=new ArrayList<>();
    private List<Fragment> list=new ArrayList<>();
    @Override
    protected int getLayoutId() {
        return R.layout.activity_add_friend;
    }

    @Override
    protected BasePreantert initPreantert() {
        return null;
    }

    @Override
    protected void initView() {

    }

    @Override
    protected void initData() {
        tab.add("找人");
        tab.add("找群");
        tabs.addTab(tabs.newTab().setText(tab.get(0)));
        tabs.addTab(tabs.newTab().setText(tab.get(1)));
        list.add(new FindSomeoneFragment());
        list.add(new FindGroupFragment());
        MyAdapter myAdapter = new MyAdapter(getSupportFragmentManager());
        vp.setAdapter(myAdapter);
        tabs.setupWithViewPager(vp);
    }
    private class MyAdapter extends FragmentPagerAdapter{

        public MyAdapter(FragmentManager fm) {
            super(fm);
        }

        @Override
        public Fragment getItem(int position) {
            return list.get(position);
        }

        @Override
        public int getCount() {
            return list.size();
        }

        @Nullable
        @Override
        public CharSequence getPageTitle(int position) {
            return tab.get(position);
        }
    }

}
